package com.test.chinamobileai.embedding;


import jakarta.annotation.PostConstruct;

import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.document.Document;
import org.springframework.ai.reader.JsonReader;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;


import java.util.List;


@Slf4j
@Component
public class RuleDateEmbedding {
      @jakarta.annotation.Resource
     VectorStore vectorStore;
    @Value("classpath:combo.json")
    private Resource resource;

    @PostConstruct
    public void init() throws Exception {
        JsonReader jsonReader = new JsonReader(this.resource, "type", "condition", "description");
        List<Document> documents = jsonReader.get();
        vectorStore.add(documents);
        log.info("写入向量库的数据:{}", documents.size());

    }


}
